package net.lab1024.sa.admin.module.business.wms.stock.controller;

import net.lab1024.sa.admin.module.business.wms.stock.domain.form.StockWarnRuleAddForm;
import net.lab1024.sa.admin.module.business.wms.stock.domain.form.StockWarnRuleQueryForm;
import net.lab1024.sa.admin.module.business.wms.stock.domain.form.StockWarnRuleUpdateForm;
import net.lab1024.sa.admin.module.business.wms.stock.domain.vo.StockWarnRuleVO;
import net.lab1024.sa.admin.module.business.wms.stock.service.StockWarnRuleServiceImpl;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

/**
 * 库存预警规则表 Controller
 *
 * @Author ADog
 * @Date 2025-09-20 16:13:18
 * @Copyright 1.0
 */

@RestController
@Tag(name = "库存预警规则表")
public class StockWarnRuleController {

    @Resource
    private StockWarnRuleServiceImpl stockWarnRuleService;

    @Operation(summary = "分页查询 @author ADog")
    @PostMapping("/stockWarnRule/queryPage")
    @SaCheckPermission("stockWarnRule:query")
    public ResponseDTO<PageResult<StockWarnRuleVO>> queryPage(@RequestBody @Valid StockWarnRuleQueryForm queryForm) {
        return ResponseDTO.ok(stockWarnRuleService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author ADog")
    @PostMapping("/stockWarnRule/add")
    @SaCheckPermission("stockWarnRule:add")
    public ResponseDTO<String> add(@RequestBody @Valid StockWarnRuleAddForm addForm) {
        return stockWarnRuleService.add(addForm);
    }

    @Operation(summary = "更新 @author ADog")
    @PostMapping("/stockWarnRule/update")
    @SaCheckPermission("stockWarnRule:update")
    public ResponseDTO<String> update(@RequestBody @Valid StockWarnRuleUpdateForm updateForm) {
        return stockWarnRuleService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author ADog")
    @PostMapping("/stockWarnRule/batchDelete")
    @SaCheckPermission("stockWarnRule:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return stockWarnRuleService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author ADog")
    @GetMapping("/stockWarnRule/delete/{ruleId}")
    @SaCheckPermission("stockWarnRule:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long ruleId) {
        return stockWarnRuleService.delete(ruleId);
    }
}
